package com.jia.leetcode2.string;

/**
 * @program: designPattern
 * @description:
 * @author: STU756
 * @create: 2021-03-25 13:48
 */
public class ValidPalindrome {
    public boolean isPalindrome(String s) {
        int i = 0, j = s.length() - 1;
        while(i < j) {
            while(i < j && !Character.isLetterOrDigit(s.charAt(i))) { ++i; }
            while(i < j && !Character.isLetterOrDigit(s.charAt(j))) { --j; }
            if(Character.toLowerCase(s.charAt(i)) != Character.toLowerCase(s.charAt(j))) {
                return false;
            }else {
                ++i;
                --j;
            }
        }
        return true;
    }
}
